package com.geek.framework.study.config.microprofile.source;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.function.Supplier;


public class ServletRequestConfigSource extends EnumerationConfigSource implements HttpServletRequestExtend{

    private final HttpServletRequest servletRequest;

    protected ServletRequestConfigSource(String name, int ordinal) {
        super(name, ordinal);
        servletRequest = getHttpServletRequest();
    }

    @Override
    protected Supplier<Enumeration<String>> getKeyResolver() {
        return servletRequest::getParameterNames;
    }

    @Override
    protected String getValueResolver(String key) {
        return servletRequest.getParameter(key);
    }


}
